package com.qf.bootmr.result;

/**
 * @author cml
 * @create 2021/5/27 10:27
 */
public class R {
    private String code;
    private String message;
    private Object data;

    public R() {
    }

    public R(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public R(String code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static R error(){
        R r = new R();
        r.setCode(RCode.FAILED.getCode());
        r.setMessage(RCode.FAILED.getMessage());
        return r;
    }

    public static R ok(){

        return new R(RCode.SUCCESS.getCode(), RCode.SUCCESS.getMessage());
    }

    public R message(String message){
        this.setMessage(message);
        return this;
    }

    public R data(Object data){
        this.setData(data);
        return this;
    }

    public R code(String code){
        this.setCode(code);
        return this;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
